{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  Wumpus.AfmLoader.Datatypes
-- Copyright   :  (c) Stephen Tetley 2012
-- License     :  BSD3
--
-- Maintainer  :  stephen.tetley@gmail.com
-- Stability   :  unstable
-- Portability :  GHC
--
-- Datatypes representing AFM (Adobe Font Metrics) files.
--
-- The representation is a subset of the info in an AFM file - 
-- many fields are dropped.
--
--------------------------------------------------------------------------------

module Wumpus.AfmLoader.Datatypes
  ( 
    AfmFile(..)
  , AfmFontMetrics(..)
  , CharMetrics(..)
    
  ) where


import Wumpus.Core                              -- package: wumpus-core

import qualified Data.Map as M

--
-- NOTE - Char codes are not unique in an AFM file.
-- /Undefined/ chars are assign char code -1.
--



data AfmFile = AfmFile
    { afm_font_metrics          :: AfmFontMetrics
    , afm_glyph_table           :: M.Map String CharMetrics
    }
  deriving (Show)

data AfmFontMetrics = AfmFontMetrics
    { afm_file_format           :: String 
    , afm_font_fullname         :: Maybe String
    , afm_encoding              :: Maybe String
    , afm_font_bbox             :: Maybe (BoundingBox AfmUnit)
    , afm_cap_height            :: Maybe AfmUnit
    , afm_ascender              :: Maybe AfmUnit
    , afm_descender             :: Maybe AfmUnit
    , afm_underline_position    :: Maybe AfmUnit  
    , afm_underline_thickness   :: Maybe AfmUnit
    }
  deriving (Show)

-- | NOTE - is bounding box useful?
--
-- Wumpus-Basic currently synthesizes a bounding box from the 
-- font bounding box and the advance vectors of the glyphs used.
--
data CharMetrics = CharMetrics
    { afm_char_code      :: !Int
    , afm_char_vector    :: !(Vec2 AfmUnit)
    }
  deriving (Show) 


